using DimensionsHelper.LanguageService.Syntax;

namespace DimensionsHelper.LanguageService;

public class AnalysisTypeBinding : AnalysisNode
{
    internal AnalysisTypeBinding(TypeBinding syntaxNode, AnalysisNode? parent) :
        base(AnalysisBoundKinds.TypeBinding, syntaxNode, parent)
    {
        Syntax = syntaxNode;
        QualifiedName = AnalysisNodeFactory.QualifiedName(
            syntaxNode.FullQualifiedName,
            this);
    }

    public override TypeBinding Syntax { get; }

    public AnalysisQualifiedName QualifiedName { get; }

    public override bool IsExpression => false;

    public override bool IsStatement => true;

    public override bool IsMetadata => false;

    public override int ChildrenCount => 1;

    public override IEnumerable<AnalysisNode> GetChildren()
    {
        return [QualifiedName];
    }

    internal override void AddChild(AnalysisNode child)
    {
        throw new NotSupportedException("AnalysisDeclaration is read-only.");
    }
}


public static partial class AnalysisNodeFactory
{
    /// <summary>
    /// 创建一个类型绑定
    /// </summary>
    /// <param name="syntaxNode">原始语法节点</param>
    /// <param name="parent">父节点</param>
    public static AnalysisTypeBinding TypeBinding(TypeBinding syntaxNode, AnalysisNode? parent)
    {
        return new AnalysisTypeBinding(syntaxNode, parent);
    }
}